<template>
	<div>
		<el-dialog
			title="物流信息"
			:visible.sync="dialogVisible"
			width="50%"
			:before-close="handleClose"
			@close="DialdgClose"
		>
			<el-timeline :reverse="false" v-if="getactivitiescount">
				<el-timeline-item
					v-for="(activity, index) in activities"
					:key="index"
					:timestamp="activity.timestamp"
				>{{activity.information}}</el-timeline-item>
			</el-timeline>
            <el-alert v-else title="暂无信息" type="info" center show-icon :closable="false"></el-alert>
			<span slot="footer" class="dialog-footer">
				<el-button type="primary" @click="dialogVisible = false">关 闭</el-button>
			</span>
		</el-dialog>
	</div>
</template>

<script>
export default {
	props: {
		dialogVisible: {
			type: Boolean,
			default: false
		},
		ID: {
			type: parseInt,
			default: 0
		}
	},
	data() {
		return {
            activities: [],
            aa:false
		}
	},
	methods: {
		handleClose(done) {
			this.$confirm('确认关闭？')
				.then(_ => {
					done()
				})
				.catch(_ => {})
		},
		//弹窗关闭事件
		DialdgClose() {
			this.$emit('DialdgClose', false)
		},
		//初始化数据
		getData() {
			this.$get('/api/OrderLogistics/GetOrderLogistics', {
				OrderID: this.ID
			})
				.then(res => {
					console.log(res)
					res.data.forEach(item => {
						item.timestamp = this.dataFormat(item.addTime)
					})
					this.activities = res.data
					console.log(this.activities)
				})
				.catch(err => {
					console.log(err)
				})
		}
	},
	watch: {
		dialogVisible: function(val) {
			if (val) {
				this.getData()
			}
		}
	},
	computed: {
		getactivitiescount() {
			return this.activities.length > 0
		}
	}
}
</script>